<template>
  <div>
      <el-breadcrumb separator="/" style="height:10px;">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>系统管理</el-breadcrumb-item>
        <el-breadcrumb-item>物品采纳</el-breadcrumb-item>
      </el-breadcrumb>
       
      
      
      <el-table
      :data="pageinfo.list"
      border
      style="width: 100%">
      <el-table-column
        prop="cid"
        label="序号"
        width="200">
      </el-table-column>

      <el-table-column
        prop="cname"
        label="名称"
        width="200">
      </el-table-column>

      <el-table-column
        prop="cprice"
        label="价格"
        width="180">
      </el-table-column>

      <el-table-column label="图片" width="150">
        <template slot-scope="scope">
          <img :src="require('../../assets/shangpin/'+scope.row.cimg)" alt="" style="width:100%;height:100%;">
        </template>
      </el-table-column>

      <el-table-column
        prop="cnumber"
        label="剩余数量"
        width="200">
      </el-table-column>

      <el-table-column
        prop="beizhu"
        label="备注"
        width="200">
      </el-table-column>

      <el-table-column label="管理操作">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="success"
            @click="caigoufn(scope.row.cid)">已采购</el-button>
        </template>
        </el-table-column>
    </el-table>
      <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="commodityVo.pageNum"
      :page-sizes="[5, 7, 10, 15]"
      :page-size="commodityVo.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pageinfo.total">
    </el-pagination>
  </div>
</template>

<script>
import {findAllCommodityQS,updateCommodityNumber} from '../../api'
export default {
  data() {
    return {
      pageinfo : {}  ,
      commodityVo : {
        pageNum : 1,
        pageSize : 5
      }
    }
  },
  created() {
    this.findAll()
  },
  methods: {
    async findAll(){
      let {data:baseRefault} = await findAllCommodityQS(this.commodityVo)
      this.pageinfo = baseRefault.data
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.commodityVo.pageNum = 1
      this.commodityVo.pageSize = val
      this.findAll()
    },
    handleCurrentChange(val) {
      this.commodityVo.pageNum = val
      console.log(`当前页: ${val}`);
      this.findAll()
    },
    async caigoufn(cid){
      let {data:baseRefault} = await updateCommodityNumber(cid)
      this.$message.success(baseRefault.message)
      this.findAll()
    }
    
  },
}
</script>

<style>

</style>